package org.project.d.network;

import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
import org.project.d.network.msg.Transmission;

import java.net.InetSocketAddress;
import java.net.SocketAddress;

/**
 * @author lin
 * @version V1.0
 * @description
 * @date 2020/6/18 3:48 下午
 */
public interface Connection {
    byte STATUS_NEW = 0;
    byte STATUS_CONNECTED = 1;
    byte STATUS_DISCONNECTED = 2;
    byte CHANNEL_TYPE_UDP=1;
    byte CHANNEL_TYPE_TCP=0;
    void init(Channel channel, SocketAddress inetSocketAddress, Byte channelType, Byte serializationType);

//    ChannelFuture send(Message message);

    ChannelFuture send(Transmission transmission);

    ChannelFuture send(TransmissionBuild transmission);

//    ChannelFuture send(Message message, ChannelFutureListener listener);

    ChannelFuture send(Transmission transmission, ChannelFutureListener listener);

    ChannelFuture send(TransmissionBuild transmission, ChannelFutureListener listener);

    String getId();

    ChannelFuture close();

    boolean isConnected();

    boolean isReadTimeout();

    boolean isWriteTimeout();

    void updateLastReadTime();

    void updateLastWriteTime();

    Channel getChannel();

    SocketAddress getAddress();

    interface TransmissionBuild{
        Transmission.TransmissionBuilder bulid(Transmission.TransmissionBuilder builder);
    }
}
